﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using SynoManager.GUI;
using SynoManager.FileStation.Gui;

namespace SynoManager.FileStation
{
    [ServiceDependency(typeof(FileStationService))]
    public class FileStationGuiPlugin : IGuiPlugin
    {
        private IHost host;
        private FileStationService service;

        public void InitializeHost(IHost host)
        {
            this.host = host;
        }

        public void Initialize(SynoDevice device)
        {
            service = device.FindService<FileStationService>();
            Debug.Assert(service != null, "FileStationService could not be found");
            service.Plugin = this;
        }

        public void PopulatePreferencesForm(TreeViewEx treeView)
        {
            
        }

        public void OnConnectionStateChange(bool isConnected, bool wasConnected)
        {
            Tab.Enabled = isConnected;
        }

        private FileStationTab tab;
        public FileStationTab Tab
        {
            get
            {
                if (tab == null)
                {
                    tab = new FileStationTab(this);
                }
                return tab;
            }
        }

        public System.Windows.Forms.Control MainControl
        {
            get { return Tab; }
        }

        public bool TabActive
        {
            set 
            { // ignore
            }
        }

        public int TabPriority
        {
            get { return 400; }
        }

        public FileStationService Service
        {
            get { return service; }
        }
    }
}
